<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>法援宝</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css" />
    <link rel="stylesheet" type="text/css" href="../css/lawyer.css" />
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../script/mobile.js"></script>
    <script type="text/javascript" src="../script/lawyer.js"></script>
</head>
<body>
<div id="secHeader">
  <header class="header">
     <!--  <a href="javascript:void(0);" onclick="api.closeWin()" class="back_btn"><img src="../image/head-fanhui.png" alt=""></a> -->
      <h2>资讯</h2>
      <!-- <a href="javascript:;" onclick="aaplay('news_find')" class="search_btn"><img src="../image/search.png" alt=""></a> -->
  </header>
</div>
<section class="news_section">
    <div class="news_kinds">
        <ul id='cate'>


        </ul>
    </div>
    <div class="news_box">
        <div class="news_title">
            <h2>文章报道</h2>
            <a href="##" class="news_more"  id='newsmore'>更多</a>
        </div>
        <div class="news_list">
            <ul id='con'>


            </ul>
        </div>
    </div>
    <div class="news_box">
        <div class="news_title">
            <h2>视频报道</h2>
            <a href="##" class="news_more" id='videomore'>更多</a>
        </div>
        <div class="video_list">
            <ul id='video'>


            </ul>
        </div>
    </div>

</section>

<section class="fixed_nav">
    <ul>
        <li class=""><a href="workbench.html"><h6 class="icon"></h6>工作台</a></li>
        <li class="active"><a ><h6 class="icon"></h6>资讯</a></li>
        <li class=""><a href="find.html"><h6 class="icon"></h6>发现</a></li>
        <li><a onclick="personal()"><h6 class="icon"></h6>我的</a></li>
    </ul>
</section>


</body>

<script>
    var p='';
    var para='';

    var cateid=0;
    var catename
    var cname='';

    apiready = function () {
      $api.fixStatusBar( $api.dom('#secHeader') );
      api.setStatusBarStyle({
          style: 'light'
      });
        


        para=api.pageParam;

        cate();
        //下拉刷新
        api.setRefreshHeaderInfo({
          visible: true,
          bgColor: 'rgba(255,255,255,255)',
          textColor: '#666',
          textDown: '下拉刷新',
          textUp: '释放刷新'
        }, function(ret, err) {
          toDoRefresh();
        });
    };

    function cate(){
        var p={type:2};
        api.ajax({
            url: webSiteUrl+'/app/public/cate',
            method: 'post',
            data: {
                values:p

            }
        }, function(ret, err) {
            api.hideProgress();

            if(ret.code==200){

               var tj=ret.data;

                cateid=tj[0].id;
                catename=tj[0].title;
                $("#newsmore"). attr("onclick","more("+cateid+','+0+")");
                $("#videomore").attr("onclick","more("+cateid+','+1+")");


                html = "";
                for(var i=0;i<tj.length;i++){

                    if(i==0){
html+='<li class="active" onclick="catenews('+tj[i].id+')" id="'+tj[i].id+'" data="'+tj[i].title+'"><a href="javascript:void(0);">'+tj[i].title+'</a></li>';
                    }else{
html+='<li class="" onclick="catenews('+tj[i].id+')" id="'+tj[i].id+'"  data="'+tj[i].title+'"><a href="javascript:void(0);">'+tj[i].title+'</a></li>';
                    }

                }
                $('#cate').html(html);

                toDoRequest()

            }else{alert(ret.msg)}
        });

    }


    function toDoRequest(){

        p= {type:cateid,newstype:0};
       // alert(JSON.stringify(p));
        api.ajax({
                url: webSiteUrl+'/app/public/news',
                method: 'post',
                data: {
                    values: p
                }
            }, function(ret, err) {
                api.hideProgress();

                if(ret.code==200){

                    html = "";
                    var tj=ret.data;
                    if(tj != null){

                    for(var i=0;i<tj.length;i++){
html+='<li onclick="newsdetail('+tj[i].id+')"><a href="javascript:;"><img src="'+webSiteUrl+tj[i].icon+'"><div class="news_info"><h6>'+tj[i].name+'</h6><div class="news_times"><em>'+tj[i].time+'</em><span>'+tj[i].plnum+'</span></div></div></a></li>';

                    }
                    }
                    $('#con').html(html)
                }else{
                    $('#con').html('<p style="text-align:center">暂无数据</p>');
                }

                videoRequest();
            });

    }
    function videoRequest(){

        p= {type:cateid,newstype:1};

        api.ajax({
                url: webSiteUrl+'/app/public/news',
                method: 'post',
                data: {
                    values: p
                }
            }, function(ret, err) {
                api.hideProgress();

                if(ret.code==200){
                    //alert(ret.data.length);return;
                    html = "";
                    var tj=ret.data;
                    if(tj != null){

                    for(var i=0;i<tj.length;i++){
html+='<li  onclick="newsdetail('+tj[i].id+')"><a href="javascript:;"><div class="video_box"><img src="'+webSiteUrl+tj[i].icon+'"><div class="shade"></div></div><div class="news_info"><h6>'+tj[i].name+'</h6><div class="news_times"><em>'+tj[i].time+'</em><span>'+tj[i].view+'</span></div></div></a></li>';



                    }
                    }

                    $('#video').html(html);
                }else{
                    $('#video').html('<p style="text-align:center">暂无数据</p>');
                }
            });

    }

    function catenews(id){
        $('#'+id).addClass('active').siblings().removeClass('active');

        $("#newsmore"). attr("onclick","more("+id+','+0+")");
        $("#videomore").attr("onclick","more("+id+','+1+")");
        //alert($("#newsmore").attr("onclick"));
        cateid=id;


        toDoRequest();
    }
    function more(id,num){
        catename=$('#'+id).attr('data');
        api.openWin({
            name: 'news_list',
            url: 'news_list.html',
            reload:true,
            pageParam: {
                id: id,
                newstype:num,
                catename:catename,
            }
        });
    }

</script>
</html>
